<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!doctype html>
<html lang="zh-CN">
<head>
<meta content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" name="viewport" />
<meta charset="utf-8">
<title>庆国企控股活动</title>
<link rel="stylesheet" href="js/alert.css" />
<style type="text/css">
body {
	background: url("http://laicunba.b0.upaiyun.com/lcb/activity/20170726gqkg_bg.jpg");
	padding: 0px;
	margin: 0px;
}
table {
    border-collapse:collapse;
}
.table-title, .table1 {
	width: 95%;
	margin: 0px auto;
	border: 1px solid #757db5;
	border-top: 0px;
	border-left: 0px;
}
.table-title {
    border-bottom: none;
}
.table-title td {
    font-size: 16px !important;
}
.table1 {
    border-top: none;
}
.table1 td, .table-title td {
	font-size: 12px;
	line-height: 28px;
	color: #FFF;
	border: 1px solid #757db5;
	border-bottom: 0px;
	border-right: 0px;
	padding: 5px 2px 5px 2px;
	text-align: center;
}

.table-title td {
	background-color: #888ca9;
	color: #FFF;
}

.current-td {
	background-color: #3f70c8 !important;
}
.btn-get {
    border-radius: 6px;
    border: none;
    color: #182166;
    height: 24px;
    line-height: 25px;
    padding: 0 12px;
    background: #7b7b7b;
}
.btn-get-active {
    background-color: #fff503;
}
#table2, #table3 {
	display: none;
}
</style>
</head>
<body>
	<img style="width: 100%;" src="http://laicunba.b0.upaiyun.com/lcb/activity/20170726gqkg_top.jpg" />
	<table class="table-title" cellspacing=0 cellpadding=0>
		<tr>
			<td class="btn-tab current-td" content_id="table1">5千元区</td>
			<td class="btn-tab" content_id="table2">1万元区</td>
			<td class="btn-tab" content_id="table3">5万元区</td>
		</tr>
	</table>
	<table id="table1" class="table1" cellspacing=0 cellpadding=0>
		<tbody>
			<tr>
				<td>5千元起投</td>
				<td>5千元起投</td>
				<td>5千元起投</td>
				<td>5千元起投</td>
				<td>5千元起投</td>
			</tr>
			<tr>
				<td>>30天以上</td>
				<td>>70天以上</td>
				<td>>100天以上</td>
				<td>>130天以上</td>
				<td>>150天以上</td>
			</tr>
			<tr>
				<td>5元红包</td>
				<td>10元红包</td>
				<td>18元红包</td>
				<td>26元红包</td>
				<td>42元红包</td>
			</tr>
			<tr>
				<td><button class="btn-get" coupon_id="20170726.5k.1">领取</button>
					<div coupon_store="store.5k.1">剩余300份</div></td>
				<td><button class="btn-get" coupon_id="20170726.5k.2">领取</button>
					<div coupon_store="store.5k.2">剩余300份</div></td>
				<td><button class="btn-get" coupon_id="20170726.5k.3">领取</button>
					<div coupon_store="store.5k.3">剩余300份</div></td>
				<td><button class="btn-get" coupon_id="20170726.5k.4">领取</button>
					<div coupon_store="store.5k.4">剩余300份</div></td>
				<td><button class="btn-get" coupon_id="20170726.5k.5">领取</button>
					<div coupon_store="store.5k.5">剩余300份</div></td>
			</tr>
		</tbody>
	</table>
	<table id="table2" class="table1" cellspacing=0 cellpadding=0>
		<tbody>
			<tr>
				<td>1万元起投</td>
				<td>1万元起投</td>
				<td>1万元起投</td>
				<td>1万元起投</td>
				<td>1万元起投</td>
			</tr>
			<tr>
				<td>>30天以上</td>
				<td>>70天以上</td>
				<td>>100天以上</td>
				<td>>130天以上</td>
				<td>>150天以上</td>
			</tr>
			<tr>
				<td>10元红包</td>
				<td>20元红包</td>
				<td>36元红包</td>
				<td>60元红包</td>
				<td>88元红包</td>
			</tr>
			<tr>
				<td><button class="btn-get" coupon_id="20170726.1w.1">领取</button>
					<div coupon_store="store.1w.1">剩余300份</div></td>
				<td><button class="btn-get" coupon_id="20170726.1w.2">领取</button>
					<div coupon_store="store.1w.2">剩余300份</div></td>
				<td><button class="btn-get" coupon_id="20170726.1w.3">领取</button>
					<div coupon_store="store.1w.3">剩余300份</div></td>
				<td><button class="btn-get" coupon_id="20170726.1w.4">领取</button>
					<div coupon_store="store.1w.4">剩余300份</div></td>
				<td><button class="btn-get" coupon_id="20170726.1w.5">领取</button>
					<div coupon_store="store.1w.5">剩余300份</div></td>
			</tr>
		</tbody>
	</table>
	<table id="table3" class="table1" cellspacing=0 cellpadding=0>
		<tbody>
			<tr>
				<td>5万元起投</td>
				<td>5万元起投</td>
				<td>5万元起投</td>
				<td>5万元起投</td>
				<td>5万元起投</td>
			</tr>
			<tr>
				<td>>30天以上</td>
				<td>>70天以上</td>
				<td>>100天以上</td>
				<td>>130天以上</td>
				<td>>150天以上</td>
			</tr>
			<tr>
				<td>50元红包</td>
				<td>100元红包</td>
				<td>180元红包</td>
				<td>263元红包</td>
				<td>420元红包</td>
			</tr>
			<tr>
				<td><button class="btn-get" coupon_id="20170726.5w.1">领取</button>
					<div coupon_store="store.5w.1">剩余300份</div></td>
				<td><button class="btn-get" coupon_id="20170726.5w.2">领取</button>
					<div coupon_store="store.5w.2">剩余300份</div></td>
				<td><button class="btn-get" coupon_id="20170726.5w.3">领取</button>
					<div coupon_store="store.5w.3">剩余300份</div></td>
				<td><button class="btn-get" coupon_id="20170726.5w.4">领取</button>
					<div coupon_store="store.5w.4">剩余300份</div></td>
				<td><button class="btn-get" coupon_id="20170726.5w.5">领取</button>
					<div coupon_store="store.5w.5">剩余300份</div></td>
			</tr>
		</tbody>
	</table>
	<img style="width: 100%;margin-top: 25px;" src="http://laicunba.b0.upaiyun.com/lcb/activity/20170726gqkg_rule.jpg" />
</body>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="js/alert.js"></script>
<script src="activity.js?v=1"></script>
<script type="text/javascript">
	$(function() {
		$(".btn-tab").click(function() {
			var contentId = $(this).attr("content_id");
			$(".table1").hide();
			$("#" + contentId).show();
			$(".table-title").find("td").removeClass("current-td");
			$(this).addClass("current-td");

		});
		$.post("20170726gqkg_store.htm", {
			t : new Date()
		}, function(data) {
			for (key in data) {
				$("div[coupon_store='" + key + "']").html(
						"剩余" + data[key] + "份");
				if(data[key]<=0){
					$("div[coupon_store='" + key + "']").parent().find("button").prop("disabled",true);
					asdadsdadsadswsssdddasdaaaaadaswdddaaadsaaaddddddddsaaaadddsssdsdddddd$("div[coupon_store='" + key + "']").removeClass("btn-get-active"); //抢红包时间内剩余份数不够按钮置灰
				}
				
			} 
		}, "json");
		Activity.ready('${param.app_token}', "20170726gqkg", "", {
			t : new Date()
		}, function(actInfo) {
			//alert(JSON.stringify(actInfo));
			$(".btn-get").click(function() {
				var couponId = $(this).attr("coupon_id");
				Activity.join(couponId, {}, function(data) {
					if (data.code == "SUCCESS") {
						$.post("20170726gqkg_store.htm", {
							t : new Date()
						}, function(data) {
							for (key in data) {
								$("div[coupon_store='" + key + "']").html(
										"剩余" + data[key] + "份");
							};
							
						}, "json");
						Lcb.alert("领取成功!");
					} else if (data.code == "token_error") {

// 						Lcb.alert("请先登录再领取");
						var device = '${param.device }';
						var location = window.location.href.split("?")[0];
						if(device) {
		 					window.location.href = location + "?device=app&app_view=login";
						} else {
							window.location.href = "/h5/login.htm?tab=account&returnUrl=" + location;
						}
					}else if (data.code == "MORE_2") {

						Lcb.alert("使用后可再次领取。");
					}else if (data.code == "STORE_EMPTY"||data.code == "AM_STORE_EMPTY"||data.code == "PM_STORE_EMPTY") {

						Lcb.alert("没抢到，很遗憾哦!");
					} else {

						Lcb.alert(JSON.stringify(data));
					}
				});
			});
		});
		
		
		var is10Clock=${is10Clock}; 
		console.log(is10Clock);
		if(!is10Clock){
			$(".btn-get").prop("disabled",true);
			$(".btn-get").removeClass("btn-get-active"); //时间不到按钮置灰
		} else {
			$(".btn-get").addClass("btn-get-active"); //时间不到按钮变亮
		}	
	});
</script>
</html>
